home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
bbsutil
/
bsrc_250.zip
/
MAILER.C
< prev
next >
Wrap
C/C++ Source or Header
|
1991-09-15
|
30KB
|
877 lines
/*--------------------------------------------------------------------------*/
/* */
/* */
/* ------------ Bit-Bucket Software, Co. */
/* \ 10001101 / Writers and Distributors of */
/* \ 011110 / Freely Available<tm> Software. */
/* \ 1011 / */
/* ------ */
/* */
/* (C) Copyright 1987-91, Bit Bucket Software Co., a Delaware Corporation. */
/* */
/* */
/* This module was written by Bob Hartman */
/* */
/* */
/* BinkleyTerm Mail Control Routines */
/* */
/* */
/* */
/* For complete details of the licensing restrictions, please refer */
/* to the License agreement, which is published in its entirety in */
/* the MAKEFILE and BT.C, and also contained in the file LICENSE.250. */
/* */
/* USE OF THIS FILE IS SUBJECT TO THE RESTRICTIONS CONTAINED IN THE */
/* BINKLEYTERM LICENSING AGREEMENT. IF YOU DO NOT FIND THE TEXT OF */
/* THIS AGREEMENT IN ANY OF THE AFOREMENTIONED FILES, OR IF YOU DO */
/* NOT HAVE THESE FILES, YOU SHOULD IMMEDIATELY CONTACT BIT BUCKET */
/* SOFTWARE CO. AT ONE OF THE ADDRESSES LISTED BELOW. IN NO EVENT */
/* SHOULD YOU PROCEED TO USE THIS FILE WITHOUT HAVING ACCEPTED THE */
/* TERMS OF THE BINKLEYTERM LICENSING AGREEMENT, OR SUCH OTHER */
/* AGREEMENT AS YOU ARE ABLE TO REACH WITH BIT BUCKET SOFTWARE, CO. */
/* */
/* */
/* You can contact Bit Bucket Software Co. at any one of the following */
/* addresses: */
/* */
/* Bit Bucket Software Co. FidoNet 1:104/501, 1:343/491 */
/* P.O. Box 460398 AlterNet 7:491/0 */
/* Aurora, CO 80046 BBS-Net 86:2030/1 */
/* Internet f491.n343.z1.fidonet.org */
/* */
/* Please feel free to contact us at any time to share your comments about */
/* our software and/or licensing policies. */
/* */
/*--------------------------------------------------------------------------*/
/* Include this file before any other includes or defines! */
#include "includes.h"
int poll_node (ADDRP);
int call_node (ADDRP, int);
int unattended ()
{
#ifdef MILQ
REGIONP OldCurWin = CurWinSet( callwin );
#endif
int no_inbound = 0;
int j, m;
long init_timer, t = -1L, t1; /* used for the timeouts */
long blank_timer;
struct _key_fnc_hdr *OldKeyFncHdr;
int done = 1; /* if we exit with this,
* get out of BT */
HFILE stream;
USHORT got;
#ifdef MILQ
HWND OldActvAccel = MilqueActvAccel;
HWND OldActvWnd = MilqueActvWnd;
MilqueActvAccel = MilqueMailerAccel;
MilqueActvWnd = MilqueMailerWnd;
SetFocus( MilqueMailerActvWnd );
#endif
un_attended = 1;
clear_statusline ();
comm_bits = BITS_8;
parity = NO_PARITY;
stop_bits = STOP_1;
program_baud ();
OldKeyFncHdr = KbMapSet (&UnattendedKeyFncHdr);
if (fullscreen)
{
screen_clear ();
sb_dirty ();
}
opening_banner ();
if (fullscreen)
{
mailer_banner ();
}
if ((stream = share_open (PRDCT_PRFX ".BAN", O_RDONLY|O_BINARY, DENY_WRITE)) != -1)
{
(void)_dos_read (stream, BBSwelcome, WELCOME_LEN, &got);
(void) close (stream);
}
else
{
BBSwelcome[0] = '\0';
}
/* Initialize the random number generator */
j = (int) time (NULL);
srand ((unsigned int) j);
status_line (MSG_TXT(M_BINK_BEGIN), ANNOUNCE, COMPILER_NAME);
set_xy ("");
set_prior(4); /* Always High */
XON_DISABLE ();
set_prior(2); /* Regular */
/* Turn off forced events */
if (noforce)
{
find_event ();
noforce = 0;
}
if (redo_dynam)
{
for (j = 0; j < num_events; j++)
{
e_ptrs[j].behavior &= ~MAT_SKIP;
}
redo_dynam = 0;
}
/*
* See if we should exit before initializing the modem (and therefore
* possibly letting a call sneak through)
*/
find_event ();
do_ready (MSG_TXT(M_READY_INIT));
/* Make sure we have all necessary parameters and that the nodelist
* index gets read in. If not, then we must exit right now.
*/
if (!net_params || !nodefind (&boss_addr, 0))
if (boss_addr.Net != 0xffff)
{
status_line (MSG_TXT(M_MISCONFIGURED));
errl_exit (254);
}
/* Set up outbound mail */
list_next_event ();
set_up_outbound ();
if (!CARRIER)
{
mdm_init (modem_init); /* Reinit modem */
}
blank_timer = timerset ((unsigned int)blank_time);/* Set a timer */
init_timer = timerset ((unsigned int)60000); /* Set a 10 minute timer */
t1 = timerset ((unsigned) next_minute ()); /* Set a 1 minute timer */
waitfor_line = timerset ((unsigned int)6000); /* no collisions for 1 min*/
top_of_mail:
un_attended = 1;
no_inbound = 0;
m = 1;
/* As long as we don't press a key */
bad_char:
more_mail = 1;
while (!(KEYPRESS () || ctrlc_ctr))
{
find_event ();
#ifdef MILQ
if ( hold_hWnd != GetFocus() )
SendMessage( node_hWnd, WM_COMMAND, GD_LAST, (long)&hist.last_addr );
#endif
/* Show that we are ready */
if (m)
{
if (fullscreen)
{
do_ready (MSG_TXT(M_READY_WAITING));
list_next_event ();
}
else
status_line (MSG_TXT(M_EVENT_WAITING), cur_event + 1);
blank_timer = timerset ((unsigned int)blank_time);/* Set a timer */
init_timer = timerset ((unsigned int)60000);/* Set a 10 min timer */
t1 = timerset ((unsigned) next_minute ()); /* Set a 1 min timer */
}
if (timeup (t1))
{
put_up_time ();
list_next_event ();
t1 = timerset ((unsigned) next_minute ()); /* Set a 1 min timer */
}
/* See if blanking interval has elapsed */
if (timeup (blank_timer))
{
blank_tim